import 'package:tender_flutter/page/home/model/cer_category_entity.dart';

cerCategoryEntityFromJson(CerCategoryEntity data, Map<String, dynamic> json) {
	if (json['code'] != null) {
		data.code = json['code'].toString();
	}
	if (json['children'] != null) {
		data.children = new List<CerCategoryEntity>();
		(json['children'] as List).forEach((v) {
			data.children.add(new CerCategoryEntity().fromJson(v));
		});
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	return data;
}

Map<String, dynamic> cerCategoryEntityToJson(CerCategoryEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['code'] = entity.code;
	if (entity.children != null) {
		data['children'] =  entity.children.map((v) => v.toJson()).toList();
	}
	data['id'] = entity.id;
	data['title'] = entity.title;
	return data;
}